/**
 * Created by henian.xu on 2018/11/5.
 *
 */

const pkg = require('../package');
const path = require('path');

function resolve(dir) {
    return path.join(__dirname, '..', dir);
}

module.exports = {
    mode: 'universal',

    // srcDir: path.join(appInfo.baseDir, './resources'),
    // rootDir: path.join(appInfo.baseDir),
    srcDir: resolve('resources'),
    rootDir: resolve(''),
    render: {
        resourceHints: false,
    },

    // Headers of the page
    head: {
        title: '搜货网 | 南安市网商网批平台', // pkg.name,
        meta: [
            {charset: 'utf-8'},
            {name: 'viewport', content: 'width=device-width, initial-scale=1'},
            {hid: 'description', name: 'description', content: pkg.description},
        ],
        link: [{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}],
    },

    // Customize the progress-bar color
    loading: {color: '#fff'},

    // Global CSS
    css: ['~/assets/style/app.scss', 'swiper/dist/css/swiper.css'],

    // Plugins to load before mounting the App
    plugins: [
        '~/plugins/axios.js',
        '~/plugins/inject.js',
        '~/plugins/filter.js',
        {src: '~/plugins/nuxt-swiper-plugin.js', ssr: false},
        '~/plugins/components.js',
    ],

    // Nuxt.js modules
    modules: [
        // Doc: https://github.com/nuxt-community/axios-module#usage
        '@nuxtjs/axios',
    ],

    // Axios module configuration
    axios: {
        // See https://github.com/nuxt-community/axios-module#options
        proxy: true,
        host: '0.0.0.0',
        port: 7002,
    },

    proxy: {
        // '/rpc': 'http://192.168.1.152:7905',
        // '/rpc': 'http://admin.pubaihui.xinchidao.com',
        '/api2': 'http://api.another-website.com',
    },

    // 路由配置
    router: {
        linkActiveClass: 'active',
        linkExactActiveClass: 'exact-active',
    },

    // Build configuration
    build: {
        // You can extend webpack config here
        vendor: ['~/plugins/components.js'],
        extend(config, ctx) {
            // Run ESLint on save
            /*if (ctx.isDev && ctx.isClient) {
                config.module.rules.push({
                  enforce: 'pre',
                  test: /\.(js|vue)$/,
                  loader: 'eslint-loader',
                  exclude: /(node_modules)/,
                })
            }*/
        },
    },
};
